README for Data/GridBuild folder

This folder contains files for building the dataset used in the model estimation.

Codes in this folder will make reference to an ESRI geodatabase 'CanasatData.gdb'. In this geodabase the raw files from
the CANASAT project should be mounted. In order to access CANASAT project shape files, contact the dataset administrators at:

INPE Av. dos Astronautas, 1758 - CEP 12227-010 - São José dos Campos - SP, Brazil. e-mail: canasat@dsr.inpe.br or webmaster@inpe.br.

For implementing the codes below, the 'CanasatData.gdb' should also contain shapefiles for lakes (Lakes.tar), urban areas (UrbanAreas.tar), 
and for the last of the wild classes ('LastWild.tar'), which are all provided here. 

%%% Datasets included in this folder:

 - Lakes.tar:         Shapefiles for waterbodies dataset used. Source: http://www.naturalearthdata.com/downloads/10m-physical-vectors/10m-lakes/
 - UrbanAreas.tar:    Shapefiles for urban areas used. Source: http://www.naturalearthdata.com/downloads/10m-cultural-vectors/10m-urban-area/
 - GeographicalRegions.gdb.tar: Compressed ArcGIS geodatabase with municipalities, micro and meso regions boundaries.
 - Rasters.gdb.tar:             Compressed ArcGIS geodatabase with rasters including:
                                - Climate information with average monthly precipitation (prec), max temperature (t_max), min temperature (t_min),
								  mean temperature (t_mean). Source: http://www.worldclim.org/.
								- Altitude and slope (computed in ArcGIS). Source: http://www.worldclim.org/.
								- Agricultural potential yields for sugarcane, soybeans and maize. Source: FAO GAEZ v3.0.
 - LastWild.tar:      Shapefiles from Last of the Wild project. This is only used in the paper to remove the Pantanal region from the sample.

%%% Codes in this folder:

All python codes below use ArcGIS libraries and were implemented using ArcMap 10. Codes are organized in the order they should be executed.
In summary, the first codes generate the grid of points for which all info from climate, land use, transportation costs, etc, will be extracted.
Next, there are codes that do this extraction and save tables in .dbf format to Data/GridBuild/Tables/. 
Then, there are codes in Matlab in the Data/GridBuild/Tables/ folder that compile all these tables into a Matlab dataset table. This final 
Matlab dataset table is the main data file Data/G1kmMiRC_V7.mat.

 - YearlyBuffer.py:   Creates buffer areas around sugarcane fields for each year. Then dissolve buffer areas and create a buffer
                      feature to be used in the next code.
 - CreateFishnets.py: Creates 1km grid of points that will form the basis of the analysis. This will call a MicroRegion feature
                      (grupings of municipalities defined by IBGE) which can be found in the compressed geodatabase 'GeographicalRegions'.
 - WorkClimate.py:    Merges climate rasters from the original dataset.
 - JoinRoadCostDistanceGrid.py:  Extract effective distance information computed by Data/TransCost/RoadTransCostRaster.py to grid points and 
                                 save Data/BuildGrid/Tables/G1kmMiRWGSRoadCostDistance.dbf table with effective distance to ports for each grid point.
								 The raster RoadCostDistanceWGS is generated by Data/TransCost/RoadTransCostRaster.py should be added to Data/GridBuild/Rasters.gdb.
 - JoinSugarDistanceGrid.py:     Joins sugarcane distances to grid and saves Tables/G1kmMiRSugRoadDist.dbf with extracted information.
                                 Rasters.gdb should have grid points and rasters with effective distances produced by Data/TransCost/SugarcaneDistances.py.
 - JoinBufferGrid.py:            Joins Buffer area to grid.
 - JoinCanaGrid.py:              Joins information on Canasat maps to grid and saves Tables/G1kmMiRCS'x'.dbf for 'x' from 2004 to 2013 and
                                 Tables/G1kmMiRSP'x'.dbf for 'x' from 2003 to 2013. It calls a 'CanasatData.gdb' that should be loaded with
                                 CANASAT project shapefiles.
 - JoinClimateGrid.py:           Joins climate info to grid.
 - JoinElevationSlopeGrid.py:    Joins elevation and slope info to grid. 
 - JoinGaezGrid.py:              Joins FAO GAEZ data info to grid.
 - JoinLakeGrid.py:              Joins Lakes to grid. 
 - JoinLastOfWildGrid.py:        Joins wild area codes on Last of the Wild maps to grid.
 - JoinMunicGrid.py:             Joins munic geocodigo from IBGE to grid.
 - JoinUrbanGrid.py:             Joins Urban areas to grid.
 - JoinXY.py:                    Joins X and Y coordinates to table.

